package com.soho.helper;

import com.soho.model.Log;

public class PrintHelper {

	public static void print(String tag,Object obj){
		System.out.println("=========="+tag+"==============");
		System.out.println(obj);
	}
	public static void print(Object obj){
		print("SYSTEM",obj);
	}
	public static void print(Exception e){
		recordLog(e,null);
	}
	public static void print(Exception e,String requestParams){
		recordLog(e,requestParams);
	}
	
	private static void recordLog(Exception e,String requestParams){
		print("Exception",e.getMessage());
		
		StringBuffer _sb = new StringBuffer();
		StackTraceElement[] ses = e.getStackTrace();
		
		if(!UtilsHelper.checkIsEmpty(requestParams)){
			_sb.append("params"+requestParams);
		}
		
		_sb.append("Exception in thread \""+e.toString());  
	    for (StackTraceElement se : ses) {  
	    	_sb.append("\tat " + se);  
	    }  
		Log.record("Exception",_sb.toString());
	}
}
